package cn.kgm.makeGodV2.ruleEngine;

import lombok.AllArgsConstructor;
import lombok.Data;
import lombok.NoArgsConstructor;

import java.util.Arrays;
import java.util.Collections;
import java.util.List;
import java.util.Map;

/**
 * @Version 1.8
 * @Author: Kappi
 * @Date: 2025-9-24 13:46
 * @Description: cn.kgm.makeGodV2.ruleEngine.ConditionConfig
 */
@Data
@NoArgsConstructor
@AllArgsConstructor
public class ConditionConfig {
    private String type;        // 条件类型：ITEM_CHECK, REALM_CHECK 或逻辑操作符 AND, OR, NOT
    private String operator;    // 操作符：>=, ==, <= 等（对于原子条件）
    private Object value;       // 条件值
    private List<ConditionConfig> conditions; // 子条件（用于逻辑操作符）
    private Map<String, Object> params; // 额外参数


    // 构造方法
    public static ConditionConfig atomic(String type, Object value) {
        ConditionConfig config = new ConditionConfig();
        config.type = type;
        config.value = value;
        return config;
    }

    public static ConditionConfig and(ConditionConfig... conditions) {
        ConditionConfig config = new ConditionConfig();
        config.type = "AND";
        config.conditions = Arrays.asList(conditions);
        return config;
    }

    public static ConditionConfig or(ConditionConfig... conditions) {
        ConditionConfig config = new ConditionConfig();
        config.type = "OR";
        config.conditions = Arrays.asList(conditions);
        return config;
    }

    public static ConditionConfig not(ConditionConfig condition) {
        ConditionConfig config = new ConditionConfig();
        config.type = "NOT";
        config.conditions = Collections.singletonList(condition);
        return config;
    }
}
